<template>
	<div class="page" style="display: flex;flex-direction: column;">
		<div class="title-content">
			<!--<div class="title">tony科技时尚生活馆</div>-->
			<div class="icon">
				<img src="../../../static/imags/shareicon.png"/>
			</div>
			<div class="search" @click="goDetail('no')">
				<i class="iconfont icon-sousuo"></i>
				<label>食品/健康/旅游</label>
			</div>
		</div>
		<div class="content">
			<mt-swipe :show-indicators="false">
			  <mt-swipe-item v-for="(item , index) in items">
			  	<img class="scroll-img" :src="item.img"/>
			  </mt-swipe-item>
			</mt-swipe>
		</div>
		<div class="goods-title"><i class="iconfont icon-iconsp2"></i>商品</div>
		<div class="tab-bar">
			<div :class="{'left-bor':index !=0}" v-for="(item,index) in tabItems" @click="goDetail(item.type)">
				<img :src="item.img"/>
				<div class="title">{{item.title}}</div>
			</div>
		</div>
		<div class="goods-title"><i class="iconfont icon-laba"></i>活动</div>
		<div class="main-activity-item" v-for="item in activities" @click="goActivity(item.main_body)">
			<img :src="item.cover_link" style="width: 100%;"/>
		</div>
		</div>
	</div>
</template>


<style>
	@import url("main.css");
	@import url("../../common/common.css");
</style>
<script>
	import $ from 'jquery'
	export default{
		name:'register',
		data:function(){
			return {
				items:[
				{
					img:require('../../../static/imags/img1.jpg'),
				}],
				tabItems:[{
					img:require('../../../static/imags/beautiful@3x.png'),
					title:'服装鞋帽',
					type:'G'
				},{
					img:require('../../../static/imags/main@3x.png'),
					title:'健康食品',
					type:'H'
				},{
					img:require('../../../static/imags/tourism@3x.png'),
					title:'定制商品',
					type:'D'
				},{
					img:require('../../../static/imags/fashion@3x.png'),
					title:'聚划算',
					type:'J'
				}],
				openId:null,
				user:{},
				activities:[]
			}
		},
		created(){
			document.title = 'tony猫欢乐生活馆';
			this.openId = this.utils.getQueryString('openId') || '';
			this.getData();
		},
		methods:{
			getData(){
				var _self = this;
				$.ajax({
				  	type:"post",
				  	contentType:'application/json;charset=UTF-8',
				  	url:this.utils.rootUrl + "activitys/1?pageSize=20&pageCount=1",
				  	data:JSON.stringify({
				  	}),
				  	success:function(res){
				  		_self.$Spin.hide();
				  		console.log(JSON.stringify(res))
				  		_self.activities = res.data;
				  	},
				  	error:function(e){
				  		_self.$Spin.hide();
				  	}
				  });
			},
			goActivity(html){
				this.$router.push({name:'activityDetail',params:{html:html}});
			},
			goDetail(type){
				if(type == 'J'){
					this.$router.push('/fc-gather?openId='+this.utils.getQueryString('openId'));
					return;
				}
				this.$router.push('/fashion/'+this.utils.getQueryString('openId')+'/'+type);
			}
		},
    		//修改列表页的meta值，false时再次进入页面会重新请求数据。  
	    beforeRouteLeave(to, from, next) {  
	        from.meta.keepAlive = true; 
	        to.meta.keepAlive = false;
	        next();  
	    } 
	}
</script>

